#ifndef __OTA_FLASH_H
#define __OTA_FLASH_H

#include "types.h"

extern uint8_t bank_ota_flag;

typedef enum{
	
	DUAL_BANK_OTA = 0,
	SINGLE_BANK_OTA	= 0x5A,
}bank_ota_t;

/**
* @fn ErrCode_t otaFlash_WriteData(uint8_t *buf, uint32_t len)
* @brief write data to OTA section.
* @param[buf] data buffer.
* @param[len] data length, the maximum value is 256.
* @return ErrCode_t:return ERR_NONE when the operation is complete
*/

ErrCode_t otaFlash_WriteData(uint8_t *buf, uint32_t len,uint32_t total_size);
/**
* @fn ErrCode_t otaFlash_CalculateCRC16(uint8_t partitionNum, uint16_t crcValue)
* @brief check crc16 for ota bin.
* @param[buf] data buffer.
* @param[len] data length, the maximum value is 256.
* @return ErrCode_t:return ERR_NONE when the operation is complete
*/
ErrCode_t otaFlash_CalculateCRC16(uint8_t partitionNum, uint16_t crcValue);
/**
* @fn otaFlash_Init(void)
* @brief ota init .
* @param none
* @return none
*/
void otaFlash_Init(void);
/**
* @fn setBootloaderUpdateInfo(void)
* @brief write ota update data .
* @param none
* @return none
*/
void setBootloaderUpdateInfo(void);
/**
* @fn enter_sigle_bank_ota(void)
* @brief write  update_info_flag to enter sigle bank ota
* @param none
* @return none
*/
void enter_sigle_bank_ota(void);

void  erase_code_flash(void);

#endif

